﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Rechargeable.Migrations
{
    public partial class serialNumber_v1 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "AppSerialNumbers",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorId = table.Column<Guid>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierId = table.Column<Guid>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterId = table.Column<Guid>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    OrderId = table.Column<Guid>(nullable: true),
                    ProductId = table.Column<Guid>(nullable: true),
                    ProductPriceId = table.Column<Guid>(nullable: true),
                    MachineId = table.Column<Guid>(nullable: true),
                    SaleUserId = table.Column<Guid>(nullable: true),
                    BuyUserId = table.Column<Guid>(nullable: false),
                    Expire = table.Column<int>(nullable: false),
                    UseTime = table.Column<DateTime>(nullable: true),
                    CreateDesc = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AppSerialNumbers", x => x.Id);
                });

            migrationBuilder.CreateIndex(
                name: "IX_AppSerialNumbers_BuyUserId",
                table: "AppSerialNumbers",
                column: "BuyUserId");

            migrationBuilder.CreateIndex(
                name: "IX_AppSerialNumbers_ProductId",
                table: "AppSerialNumbers",
                column: "ProductId");

            migrationBuilder.CreateIndex(
                name: "IX_AppSerialNumbers_SaleUserId",
                table: "AppSerialNumbers",
                column: "SaleUserId");

            migrationBuilder.CreateIndex(
                name: "IX_AppSerialNumbers_BuyUserId_SaleUserId_ProductId",
                table: "AppSerialNumbers",
                columns: new[] { "BuyUserId", "SaleUserId", "ProductId" });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "AppSerialNumbers");
        }
    }
}
